home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: Bradd W. Szonye <bradds@ix.netcom.com>
- Newsgroups: comp.lang.c++
- Subject: RE: Beginner: Some Questions
- Date: 20 Apr 1996 20:04:13 GMT
- Organization: Netcom
- Message-ID: <01bb2ef5.2ad6b540$8ec2b7c7@Zany.localhost>
- References: <N.041596.214427.72@slipper163167.bcs.iafrica.com>
- NNTP-Posting-Host: det-mi4-14.ix.netcom.com
- X-NETCOM-Date: Sat Apr 20 3:04:13 PM CDT 1996
- X-Newsreader: Microsoft Internet News
-
-
- On Monday, April 15, 1996, herbi@iafrica.com wrote...
- > Hi
- > I am a C++ beginner. I programmed in T.Pascal, and now i need someting
- new. The
- > basic commands in Pascal is the same as in C++.
- > I have some questions, i know how to do it in Pascal,but not in C++. If
- you
- > can, could you perhaps answer them for me.
- >
- > 1) How do you repeat a statement for a certen amout of times, or until a
- key is
- > pressed?
-
- To repeat a statement N times:
-
- size_t i;
- for (i = 0; i < N; i++) {
- // do stuff
- }
-
- The second half is OS-specific, but for hints look in your compiler's help
- regarding the header <conio.h>, which exists under both MSVC++ and Borland
- C++ (I think).
-
- > 2) How do you activate the mouse or mouse driver?
-
- This is OS-specific and very complex. I suggest getting a good book on
- programming for Windows to learn about event-driven programming.
- "Programming Windows" by Charles Petzold is the "definitive" book, and
- "Inside Visual C++" by Kruglinski is good if you're using Visual C++. Make
- sure you get the right version of the book though--different editions are
- aimed at different Windows versions.
-
- I'd recommend *not* learning how to program the mouse under DOS... it's
- fairly difficult and (hopefully) obsolete.
-
- > 3) How do you open a text file, input data or read data?
-
- If the maximum length of a line is N:
-
- char buffer[N];
- ifstream istr("filename");
-
- istr.getline(buffer, sizeof buffer);
- while (istr) {
- // do stuff with text line
- istr.getline(buffer, sizeof buffer);
- }
-
- > 4) How do you get 256 colors in C++?
-
- This is a topic which requires a bit of experience in Windows programming
- and is probably not worthwhile for DOS programming. In fact, learning
- anything for DOS programming with a fairly large learning curve may be a
- bad use of your time. Start learning how to program for Windows; if you're
- intending to do any kind of professional programming, you may need to.
-
- > I you could answer this few questions it would help me a lot in
- programming.
- > If you know of a site or ftp which have c++ source files or anything to
- do with
- > C++ programming, could you give it to me please.
-
- This is an area where you may actually want to visit Borders Books (or
- your favorite store) before consulting the Internet. With the current
- chaotic state of the C++ language, stuff on the Internet is very likely to
- be confusing and contradictory. This isn't because net users are idiots.
- Rather, any question like "how do I do this" or "is this legal" is likely
- to get different answers from Microsoft, Borland, gnu, Sun, HP, Watcom,
- etc. users. If you do ask questions, be sure to include which OS and
- compiler you're using, including the version.
-
- > Thanks
- > Cheers!!
- > email:herbi@iafrica.com
-
-
-